package com.taihe.service.impl;

import com.taihe.dao.UserMapper;
import com.taihe.domain.User;
import com.taihe.domain.UserExample;
import com.taihe.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by zwt on 2018/7/20.
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    @Override
    public List<User> selectAll() {
        UserExample userExample = new UserExample();
        return userMapper.selectByExample(userExample);
    }

    @Override
    public User selectOne(Long id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class,readOnly = false)
    //@Transactional(rollbackFor = {Exception.class},readOnly = false)
    public int save(User user) {
        int i = userMapper.insertSelective(user);
        int a = 1 / 0;
        return i;
    }
}
